<template>
	<view class="content">
		作为express建立服务器的一个示例
	</view>
</template>

<script>
	export default {
		data() {
			return {
			}
		},
		onLoad() {
			//get请求
			uni.request({
				url: 'http://localhost:3000/testgetparams',
				method: 'GET',
				data: {
					name:'猪八戒',
					age:15,
					hobby:'调戏嫦娥'
				},
				success: res => {
					console.log("这是一个get请求")
					console.log(res)
				},
				fail: () => {},
				complete: () => {}
			});
			//post请求
			uni.request({
				url: 'http://localhost:3000/testpostbody',
				method: 'POST',
				 header: {'content-type': 'application/x-www-form-urlencoded'} ,
				data: {
					name:'孙悟空',
					age:15,
					hobby:'欺负猪八戒'
				},
				success: res => {
					console.log("这是一个post请求")
					console.log(res)
				},
				fail: () => {},
				complete: () => {}
			});
		},
		methods: {
			
		}
	}
</script>

<style>
	
</style>
